package file;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.Scanner;

public class Jab {
    public static void main(String[] args) throws IOException {
        /*for (int i=0;i<=100;i++){
            File file=new File(".txt"+i+".txt");
            if (file.isDirectory()){
                System.out.println("已存在");
            }else{
                file.createNewFile();
            }
        }
        System.out.println("已创建");


for (int i=0;i<=100;i++) {
    File file1 = new File(".txt" + i + ".txt");
    if (file1.exists()) {
        file1.delete();
    }
}
        System.out.println("已删除");


        Scanner scan=new Scanner(System.in);*/
        /*System.out.println("请输入一个目录名...");
        String name= scan.nextLine();
        File file=new File(name);
        if (file.exists()){
            System.out.println("已存在");
        }else {
            file.mkdirs();
            System.out.println("已创建");
        }*/



       /* System.out.println("请输入要删除的目录名...");
        String name1= scan.nextLine();
        File file1=new File(name1);
        if (file1.exists()){
            file1.delete();
            System.out.println("删除");
        }else {
            System.out.println("不存在");
        }*/


        File file1 = new File(".");
        if (file1.isDirectory()) {
            File[] sub = file1.listFiles(file -> file.getName().endsWith(".txt"));
            for (File ss : sub) {
                System.out.println(ss.getName());
            }
        }





        Scanner scan=new Scanner(System.in);
        while (true){
            System.out.println("请输入文件名");
            String name=scan.nextLine();
            File file=new File(name);
            if (file.exists()){
                System.out.println("已存在");
            }else{
                file.createNewFile();
                System.out.println("已创建");
                break;
            }
        }



    }
}
